<?php


namespace App\Repository\Repositories;

use App\Http\Controllers\Controller;
use App\Models\StoreMember;
use App\Repository\RepositoryInterface\StoreMemberInterface;

class StoreMemberRepositories extends Controller implements StoreMemberInterface
{
    protected $member;

    public function __construct(StoreMember $storeMember)
    {
        $this->member = $storeMember;
    }
    /**
     * 查询添加核销员列表
     * @return array
     */
    public function memberList(){
        try {
            $res = StoreMember::memberList();
            return parent::success("查询成功",$res);
        }catch (\Exception $exception){
            return parent::error($exception->getMessage());
        }
    }

    /**
     * 添加核销员
     * @param $params
     * @return array
     */
    public function addMember($params){
        try {
            foreach ($params as $k=>$v){
                $res = $this->member::addMember($v);
            }
            return parent::success("添加成功",$res);
        }catch (\Exception $exception){
            return parent::error($exception->getMessage());
        }

    }

    /**
     * 核销员列表
     * @return array
     */
    public function verifierList(){
        try {
            $res = StoreMember::verifierList();
            return parent::success("查询成功",$res);
        }catch (\Exception $exception){
            return parent::error($exception->getMessage());
        }
    }

    /**
     * 核销员删除
     * @param $id
     */
    public function delVerifier($id){
        try {
            $res = StoreMember::delVerifier($id);
            return parent::success("删除成功",$res);
        }catch (\Exception $exception){
            return ['code'=>400,'msg'=>$exception->getMessage()];
        }
    }
}
